<%@ include file="/WEB-INF/jspf/taglib.jspf" %>
<%-- Set language based on user's choice --%>
<c:if test="${!empty language}">
    <fmt:setLocale value="${language}" scope="session" />
</c:if>
<%@ page language="java" import="java.util.*" %>

<%String data = request.getParameter("userlog");%>

<% if (session.getAttribute("isLogin") == "1") {%>
<!--Form Function-->
<script type="text/javascript">
    // pre-submit callback
    function showRequest(formData, jqForm, options) {
        //var queryString = $.param(formData);
        return true;
    }

    // post-submit callback
    function showResponse(responseText, statusText, xhr, $form)  {
        BindJsonToHtml(responseText);
    }
</script>
<!--End Form Function-->

<!--Page Load-->
<script type="text/javascript" >
    $(document).ready(function() {
        /**
         * LoadData
         */
        //            $.ajax({
        //                url: "SRV/CureplanDetail/getJson" ,
        //                type: "POST",
        //                async: false, // temporarily lock the browser, disabling any actions while the request is active
        //                data: {
        //                    curePlanId: $("#curePlanId").val()
        //                },
        //                dataType: "json",
        //                success: function(data){
        //
        //                    $("#formCureplan").find("input, select, button, textarea").uniform({selectClass: 'selector full_width width-100'});
        //                    $("#datDateMinAccept").datepicker();
        //                    $("#datDateMaxAccept").datepicker();
        //                    $("#btnReset").click(function(){
        //                        $("#formCureplan").get(0).reset();
        //                        $.uniform.update("#formCureplan input, #formCureplan textarea, #formCureplan select,#formCureplan button");
        //                        return false
        //                    });
        //                    //!Must Bind after uniform process
        //
        //                    BindJsonToHtml(data);
        //
        //                    $.uniform.update("#formCureplan input, #formCureplan textarea, #formCureplan select,#formCureplan button");
        //
        //                    //Balance Form Height
        //                    BalanceFormHeight();
        //
        //                    $("#formCureplan").validate({
        //                        rules: {
        //                            txtSymptom : "required",
        //                            chkAcceptCondition : "required"
        //                            //                        txtPriceMinAccept : {
        //                            //                            required: true,
        //                            //                            number: true
        //                            //                        },
        //                            //                        txtPriceMaxAccept : {
        //                            //                            required: function(element) {
        //                            //                                var minPrice = $('#txtPriceMinAccept').val();
        //                            //                                var maxPrice = $('#txtPriceMaxAccept').val();
        //                            //
        //                            //                                if(parseInt(minPrice) >= parseInt(maxPrice)){
        //                            //                                    $('#errorLabel').css('display', 'block');
        //                            //                                    return false;
        //                            //                                }
        //                            //                                else
        //                            //                                    $('#errorLabel').hide();
        //                            //                                return true;
        //                            //                            }
        //                            //                        }
        //                        },
        //                        messages: {
        //                            txtSymptom : "Please enter Symptom",
        //                            chkAcceptCondition : "Please&nbsp;accept&nbsp;Terms&nbsp;and&nbsp;Conditions"
        //                        },
        //                        submitHandler: function(form) {
        //                            $(form).ajaxSubmit({
        //                                url: '<%=request.getContextPath()%>/SRV/CureplanDetail/formCureplan_Submit?'+$(form).serialize(),
        //                                type: 'POST',
        //                                dataType:  'json',
        //                                beforeSubmit:  showRequest,  // pre-submit callback
        //                                success:       showResponse  // post-submit callback
        //                            });
        //                        }
        //                    });
        //                    $("#txtPriceMinAccept").blur(function() {
        //                        $("#txtPriceMaxAccept").valid();
        //                        $("#txtPriceMinAccept").valid();
        //                    });
        //                }
        //            });
        /**
         * End LoadData
         */

        /**
         * Bind Tab&Dialog
         */

        /**
         * End Bind Tab&Dialog
         */

        /**
         * Bind Event
         */

        /**
         * End Bind Event
         */
    });
</script>
<!--End Page Load-->
<span class="content clearfix">
    <div class="left">
        <h1><fmt:message key="Welcome"/></h1>

        <fmt:message key="Editprofile"/><a onclick="HeaderMenuClick('SRV/MUserDetail', 'section #container', this)"><fmt:message key="click"/> &raquo; </a><br/>
        <input type="button" name="btnLogout" value="Logout" class="bt_login" onclick="ContentAjaxRequest('login/logout', '#panel')"/>
        <img src="images/user.png"/>
    </div>
    <div class="left">
        <% if ("user".equals(data)) {%>
        <h1>Plan </h1>
        <h2>My Plan</h2>
        <p class="grey">You can find your cure plan from the status, doctor name,...as <a href="javascript:ContentAjaxRequest('SRV/SRV_CureplanList', 'section #container')" title="Download">follows click &raquo;</a></p>
        <%} else if ("doctor".equals(data)) {%>
        <h1>Plan </h1>
        <h2>Doctor Plan</h2>
        <p class="grey">You can find all the services from the price, doctor name, hospital as<a href="javascript:ContentAjaxRequest('SRV/CurePlanProviderList', 'section #container')"> follows click &raquo;</a></p>
        <%} else if ("admin".equals(data)) {%>
        <h1>Master Data</h1>
        <p class="grey">Doctor<a href="javascript:ContentAjaxRequest('SRV/MDoctorList', 'section #container')"> follows click &raquo;</a></p>

        <p class="grey">Hospital<a href="javascript:ContentAjaxRequest('SRV/MHospitalList', 'section #container')"> follows click &raquo;</a></p>

        <p class="grey">Hotel<a href="javascript:ContentAjaxRequest('SRV/MHotelList', 'section #container')"> follows click &raquo;</a></p>

        <p class="grey">Service<a href="javascript:ContentAjaxRequest('SRV/CureServiceList', 'section #container')"> follows click &raquo;</a></p>

        <p class="grey">Doctor Service (ESB)<a href="javascript:ContentAjaxRequest('WebServiceClient/WSC_insertDoctor', 'section #container')"> follows click &raquo;</a></p>

        <p class="grey">Treatment Service (ESB)<a href="javascript:ContentAjaxRequest('WebServiceClient/WSC_insertTreatment', 'section #container')"> follows click &raquo;</a></p>
        <%}%>
    </div>
    <div class="left right">

    </div>
</span>
<% } else {%>
<!--Form Function-->
<script type="text/javascript">
    // pre-submit callback
    function showRequest(formData, jqForm, options) {
        var queryString = $.param(formData);
        return true;
    }

    // post-submit callback
    function showResponse(responseText, statusText, xhr, $form)  {
        ContentAjaxRequest('login/login', '#panel')
    }
</script>
<!--End Form Function-->

<!--Page Load-->
<script type="text/javascript" >
    $(document).ready(function() {
        /**
         * LoadData
         */
        $("#formLogin").validate({
            rules: {
                log : {
                    required : true,
                    minlength : 8
                },
                pwd : "required"
            },
            messages: {
                log : {
                    required : "Please enter Username",
                    minlength : "Minimun 8 Character"
                },
                pwd : "Please enter Password"
            },
//            errorPlacement: function(error, element) {
//                error.appendTo( element.parent("#formLogin").next("#lblLog") );
//            },
            submitHandler: function(form) {
                $(form).ajaxSubmit({
                    url: '<%=request.getContextPath()%>/login/doLogin?'+$(form).serialize(),
                    type: 'POST',
                    dataType:  'json',
                    beforeSubmit:  showRequest,  // pre-submit callback
                    success:       showResponse  // post-submit callback
                });
            }
        });
        /**
         * End LoadData
         */

        /**
         * Bind Tab&Dialog
         */

        /**
         * End Bind Tab&Dialog
         */

        /**
         * Bind Event
         */

        /**
         * End Bind Event
         */
    });
</script>
<!--End Page Load-->
<span class="content clearfix">
    <div class="left">
        <h1><fmt:message key="WelcometoMedicalHub"/></h1>
        <h2><fmt:message key="Login&Register"/></h2>
        <p class="grey"><fmt:message key="Detaillogin"/></p>

    </div>
    <div class="left">
        <!-- Login Form -->
        <form class="clearfix" id="formLogin" class="form clearfix">
            <h1><fmt:message key="Login"/></h1>
            <label id="lblLog" class="grey" for="log"><fmt:message key="Username"/>:</label>
            <input class="field" type="text" name="log" id="log" value="" size="23" />
            <label class="grey" for="pwd"><fmt:message key="Password"/>:</label>
            <input class="field" type="password" name="pwd" id="pwd" size="23" />
            <label><input name="rememberme" id="rememberme" type="checkbox" checked="checked" value="forever" /> &nbsp;<fmt:message key="Rememberme"/></label>
            <div class="clear"></div>
            <input type="submit" name="btnLogin" id="btnLogin" value="Login" class="bt_login" />
            <a class="lost-pwd" href="#"><fmt:message key="Lostpass"/></a>
        </form>
    </div>
    <div class="left right">
        <!-- Register Form -->
        <form action="#" method="post">
            <h1><fmt:message key="Register"/></h1>
            <label class="grey" for="signup"><fmt:message key="Username"/>:</label>
            <input class="field" type="text" name="signup" id="signup" value="" size="23" />
            <label class="grey" for="email"><fmt:message key="Email"/>:</label>
            <input class="field" type="text" name="email" id="email" size="23" />
            <label><fmt:message key="Detailregister"/></label>
            <input type="submit" name="submit" value="Register" class="bt_register" />
        </form>
    </div>
</span>
<% }%>

